<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body class="z1">
    <p>p1</p>
    <p class="p1">p2</p>
    <p class="p1">p3</p>
    <a href="" name="a1">a1</a>
    <a href="" name="a1">a2</a>
    <a href="" name="a1">a3</a>
    <script>
      console.log(document.querySelectorAll("body p")); //标签选择器
      console.log(document.getElementsByTagName("p")); //标签名
      //---
      console.log(document.querySelectorAll(".p1")); //类选择器
      console.log(document.getElementsByClassName("p1")); //类名
      //---
      console.log(document.querySelectorAll('[name="a1"]')); //属性选择器
      console.log(document.getElementsByName("a1")); //name属性名
    </script>
  </body>
</html>
